<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript" src="../../js/jquery-3.1.1.min.js"></script>
<script type="text/javascript" src="../../js/jquery.easyui.min.js"></script>
<script type="text/javascript" src="../../js/easyui-lang-zh_CN.js"></script>
<script type="text/javascript" src="../../js/menu/menu.js"></script>
<link rel="stylesheet" type="text/css" href="../../css/extEasyUIIcon.css">
<link rel="stylesheet" type="text/css" href="../../css/demo.css">
</head>
<body>
	<div id = "test" class="easyui-layout" data-options="fit:true,border:false">
	    <div data-options="region:'center',border:false" title="" style="overflow: hidden;padding:10px 60px 20px 60px">
			<form id="ff" method="post">
				<table cellpadding="5px;">
					<div class="fitem">
						<label>菜单编码:</label>
						<input name="menuCode" class="easyui-validatebox" required="true">
					</div>
					<div class="fitem">
						<label>菜单名称:</label>
						<input name="menuName" class="easyui-validatebox" required="true">
					</div>
					<div class="fitem">
						<label>父菜单ID:</label>
						<input name="parent" class="easyui-validatebox" required="true">
					</div>
					<div class="fitem">
						<label>URL:</label>
						<input name="url" class="easyui-validatebox" required="true">
					</div>
				</table>
			</form>
		</div>
	</div>
	<div id="dlg-buttons">
		<a href="#" class="easyui-linkbutton" iconCls="icon-ok" onclick="saveUser()">Save</a>
		<a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#dlg').dialog('close')">Cancel</a>
	</div>
<script type="text/javascript" src="../../js/menu/menuList.js"></script>	
<script type="text/javascript" >
	$(function(){
		$.fn.serializeObject = function(){  
		   var o = {};  
		   var a = this.serializeArray();  
		   $.each(a, function() {  
		       if (o[this.name]) {  
		           if (!o[this.name].push) {  
		               o[this.name] = [o[this.name]];  
		           }  
		           o[this.name].push(this.value || '');  
		       } else {  
		           o[this.name] = this.value || '';  
		       }  
		   });  
		   return o;  
		};
		//回显信息
		$('#ff').form('load','/menu/_/'+menuId);
		
		$("#ff").bind("submit",function(e){
			e.preventDefault();
			var jsonuserinfo = $(this).serializeObject();
			$.messager.progress({// 显示一个进度条 
				title : '提示',
				text : '数据处理中，请稍后....'
			});	
			var isValid= $(this).form('validate');
			if(isValid){
				$.ajax({
					url: '/menu/_/'+menuId,
					type:"put",
					headers: { 
						'Accept': 'application/json',
						'Content-Type': 'application/json' 
						},
					data:JSON.stringify(jsonuserinfo),
					success: function(result){
						$.messager.progress('close');
						$('#dg').datagrid('reload'); 
						$.modalDialog.handler.dialog('close');
					}
				});
			}else{
				$.messager.progress('close');	// 当form不合法的时候隐藏工具条
			}
		});
	});
</script>
</body>
</html>